package com.example.demo.configuration;


import com.example.demo.controller.interceptor.ProjectInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.List;

//他是在这里跳转的,从这里跳到resource目录的视图文件返回去
@Slf4j
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    /**
     * 设置静态资源映射
     * @param registry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        log.info("开始进行静态资源映射...");//把所有的静态资源的访问路径给传到resource下访问
        registry.addResourceHandler("/webapp/**").addResourceLocations("classpath:/webapp/");
        registry.addResourceHandler("/webapp/**").addResourceLocations("classpath:/webapp/");
        registry.addResourceHandler("/test/**").addResourceLocations("classpath:/test/");
    }


    //在此次开启拦截器
//    @Autowired
//    private ProjectInterceptor loginCheckInterceptor;
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**");//注册拦截器.拦截所有资源
//    }


}
